home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / ABox 1.9.5 / CPlus Files / ABStr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-26  |  4.7 KB  |  202 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABStr.c
  15.  
  16. NAME
  17.     ABStr.c, part of the ABox project source code,
  18.     responsible for handling the AboutBox Str class stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                ttempel@monmouth.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <ttempel@monmouth.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     9 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     28-july-94    -    ty    -    1.0.6--additions to support settable speech mgr usage
  38.                                     via the ABox Get/SetProperty methods
  39.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  40.                             release and the associated Universal Headers from Apple:
  41.                             most methods that returned references now have "Ref" at
  42.                             the end of their methods names to prevent possible collisions
  43.                             with datatypes and classes of the same name (older versions
  44.                             of the compiler didn't have a problem with this).
  45.     25-oct-95    -    ty    -    changes for "const" usage under CW7; simplification of Boolean
  46.                             query methods
  47.  
  48. */
  49.  
  50. /*===========================================================================*/
  51.  
  52. /*======= Segmentation directives ========*/
  53.  
  54. #ifdef USE_MANUAL_SEGMENTATION
  55. #pragma segment ty
  56. #endif
  57.  
  58. /*============ Header files ==============*/
  59.     
  60. #include     "ABStr.h"
  61. #include    "ABox.h"
  62.  
  63. /*=============== Globals ================*/
  64.  
  65. /*================ CODE ==================*/
  66.  
  67.  
  68. /*=============================== ABStr::ABStr ================================*/
  69. ABStr::ABStr(void)
  70. {
  71.     mResType = kABStringResource;
  72. } // end ABStr
  73.  
  74.  
  75.  
  76. /*=============================== ABStr::~ABStr ================================*/
  77. ABStr::~ABStr(void)
  78. {
  79. } // end ~ABStr
  80.  
  81.  
  82.  
  83.  
  84.  
  85. /*=============================== ABStr::Draw ================================*/
  86. OSErr    ABStr::Draw(WindowPtr window)
  87. {
  88.     OSErr        error = noErr;
  89.     Rect        box;
  90.     
  91.     //    begin here...
  92.     
  93.     error = ABObject::Draw(window);
  94.     if (error == noErr)
  95.     {
  96.             
  97.         //    get the display area...
  98.         //
  99.         box = this->ObjectRect();
  100.         
  101.         error = this->InitializeResource();
  102.     
  103.         if (!this->HasResourceHandle())
  104.             return noErr;
  105.     
  106.         ::HLockHi (this->ResourceHandleRef());
  107.         if (**(this->ResourceHandleRef()) > 0) 
  108.         {
  109.             error = this->DrawTextBox ((unsigned char *)&((*(this->ResourceHandleRef()))[1]),    //    unsigned char *c
  110.                                 **(this->ResourceHandleRef()),                    //    unsigned long textSize
  111.                                 &box,                            //    Rect *displayWrapRect
  112.                                 teJustCenter,                     //    short alignmentConstants
  113.                                 0,                                //    lineHeightCode (0 = default)
  114.                                 NULL,                            //    short *endY baseline
  115.                                 NULL);                            //    short *lineHeight
  116.         } // end if block
  117.         ::HUnlock (this->ResourceHandleRef());
  118.     
  119.     }
  120.     
  121.     return error;
  122.     
  123. } // end Draw
  124.  
  125.  
  126.  
  127.  
  128. /*=============================== ABStr::Event ================================*/
  129. Boolean    ABStr::Event(EventRecord *event)
  130. {
  131.     Boolean        handled = false;
  132.     Point        where;
  133.     OSErr        error = noErr;
  134.     
  135.     //    begin here...
  136.     //
  137.     if (!event)
  138.         return handled;
  139.     
  140.     switch (event->what) 
  141.     {
  142.         case    mouseDown:    
  143.             //    1.0.6 ty--check to see if we're allowed to use the Text-To-Speech Mgr
  144.             //
  145.             ABox *theABox = (ABox *)::GetWRefCon (this->OurWindowRef());
  146.             Boolean    useSpeech = false;
  147.             
  148.             if (theABox)
  149.                 error = theABox->GetProperty(kABoxUseSpeechMgr, &useSpeech, NULL);
  150.             
  151.             where = event->where;
  152.             ::GlobalToLocal(&where);
  153.             if (::PtInRect (where, &(this->ObjectRect())) && 
  154.                 (::FrontWindow() == this->OurWindowRef()) && 
  155.                 ABUEnvSpeechSynth::IsPresent() && 
  156.                 useSpeech) 
  157.             {
  158.                 //    Stop speaking first
  159.                 error = End();
  160.                 
  161.                 //    speak the string!
  162.                 if (this->HasResourceHandle())
  163.                 {
  164.                     ::HLock(this->ResourceHandleRef());
  165.                     error = ::SpeakString ((StringPtr)*(this->ResourceHandleRef()));
  166.                     ::HUnlock(this->ResourceHandleRef());
  167.                     if (!error)
  168.                         handled = true;
  169.                 } // end if block
  170.             } // end if block
  171.             break;
  172.         default:
  173.             break;
  174.     } // end switch block
  175.     
  176.     return handled;
  177. } // end Event
  178.  
  179.  
  180.  
  181. /*=============================== ABStr::Stop ================================*/
  182. OSErr    ABStr::Stop(void)
  183. {
  184.     OSErr    error = noErr;
  185.     
  186.     //    begin here...
  187.     //
  188.     error = this->End();
  189.     error = ABResource::Stop();
  190.     return error;
  191.     
  192. } // end Stop
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200. //    end of file
  201.  
  202.